# Maintainer: Antoine Lambert <antoine.lambert@inria.fr>

_realname=tulip
pkgbase="mingw-w64-${_realname}"
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_pre=
_ver=5.5.1
pkgver=${_ver}${_pre}
pkgrel=2
pkgdesc="Large graphs analysis, drawing and visualization framework"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://tulip.labri.fr/"
license=('LGPL')
options=('strip' 'staticlibs')
source=("https://sourceforge.net/projects/auber/files/tulip/${_realname}-${_ver}${_pre}/${_realname}-${_ver}${_pre}_src.tar.gz"
        "001-fix-tulip-python-install.patch")
sha256sums=('afd4b2052a9d33198d8e4a0a717474511b1f06e26b9a3eac2ac8c8f12af0b4c3'
            '87f788a27483d15cbb0c7c3a9fd8e9a222207584ff1a4990bdc2905c19845f39')
depends=("${MINGW_PACKAGE_PREFIX}-freetype"
         "${MINGW_PACKAGE_PREFIX}-glew"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-libjpeg"
         "${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-qhull"
         "${MINGW_PACKAGE_PREFIX}-qt5-base"
         "${MINGW_PACKAGE_PREFIX}-qt5-xmlpatterns"
         "${MINGW_PACKAGE_PREFIX}-qtwebkit"
         "${MINGW_PACKAGE_PREFIX}-quazip"
         "${MINGW_PACKAGE_PREFIX}-yajl")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-cmake"
             "${MINGW_PACKAGE_PREFIX}-doxygen"
             "${MINGW_PACKAGE_PREFIX}-sip"
             "${MINGW_PACKAGE_PREFIX}-python-sphinx"
             "${MINGW_PACKAGE_PREFIX}-qt5-tools")

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -p1 -i ${srcdir}/001-fix-tulip-python-install.patch
}

build() {
  [[ -d "${srcdir}/build-${MSYSTEM}" ]] && rm -rf "${srcdir}/build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_NEED_RESPONSE=ON \
    -DTULIP_FIXUP_BUNDLE=OFF \
    -DPYTHON_EXECUTABLE=${MINGW_PREFIX}/bin/python3.exe \
    -DTULIP_PYTHON_SITE_INSTALL=ON \
    ../${_realname}-${_ver}${_pre}

  cmake --build .
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  DESTDIR=${pkgdir} cmake --install .
}
